/*
    This file is part of SQLiteGTK, written by Aly Hirani

    SQLiteGTK is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    SQLiteGTK is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with SQLiteGTK.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _PREFS_MANAGER_H_
#define _PREFS_MANAGER_H_

struct _PrefsManager
{
	GKeyFile *key_file;
	gchar *file_path;
};

/**
 * A structure that manages the application preferences. The internal members of this struct
 * should not be directly accessed. Instead, methods are provided for accessing the internal structures
 * properly. Data written to the harddisk is in the form of GKeyFile (ini) files.
 */
typedef struct _PrefsManager PrefsManager;

/**
 * Create a new instance of PrefsManager from the given config file at file_path
 */
PrefsManager *prefs_manager_new(const gchar *file_path);

/**
 * Free a given instance of a PrefsManager 
 */
void prefs_manager_free(PrefsManager *prefs_manager);

/**
 * Returns whether the PrefsManager has the given key in the given group_name
 */
gboolean prefs_manager_has_key(PrefsManager *prefs_manager, const gchar* group_name, const gchar *key);

/**
 * Gets an integer preference from the PrefsManager
 */
gint prefs_manager_get_int(PrefsManager *prefs_manager, const gchar* group_name, const gchar* key_name, gint default_value);

/**
 * Sets an integer preference in the PrefsManager
 */
void prefs_manager_set_int(PrefsManager *prefs_manager, const gchar *group_name, const gchar *key_name, gint value);

/**
 * Returns whether an integer preference with the given value exists in the PrefsManager
 */
gboolean prefs_manager_equals_int(PrefsManager *prefs_manager, const gchar *group_name, const gchar *key_name, gint value);

/**
 * Gets an boolean preference from the PrefsManager
 */
gboolean prefs_manager_get_bool(PrefsManager *prefs_manager, const gchar* group_name, const gchar* key_name, gboolean default_value);

/**
 * Sets a boolean preference in the PrefsManager
 */
void prefs_manager_set_bool(PrefsManager *prefs_manager, const gchar *group_name, const gchar *key_name, gboolean value);

/**
 * Returns whether a boolean preference with the given value exists in the PrefsManager
 */
gboolean prefs_manager_equals_bool(PrefsManager *prefs_manager, const gchar *group_name, const gchar *key_name, gboolean value);

/**
 * Gets an boolean preference from the PrefsManager
 */
gdouble prefs_manager_get_double(PrefsManager *prefs_manager, const gchar* group_name, const gchar* key_name, gdouble default_value);

/**
 * Sets a double preference in the PrefsManager
 */
void prefs_manager_set_double(PrefsManager *prefs_manager, const gchar *group_name, const gchar *key_name, gdouble value);

/**
 * Returns whether a boolean preference with the given value exists in the PrefsManager
 */
gboolean prefs_manager_equals_double(PrefsManager *prefs_manager, const gchar *group_name, const gchar *key_name, gdouble value);

/**
 * Gets a char* preference in the PrefsManager
 */
gchar *prefs_manager_get_string(PrefsManager *prefs_manager, const gchar* group_name, const gchar* key_name, const gchar* default_value);

/**
 * Sets a char* preference in the PrefsManager
 */
void prefs_manager_set_string(PrefsManager *prefs_manager, const gchar *group_name, const gchar *key_name, gchar* value);

/**
 * Returns whether a char* preference with the given value exists in the PrefsManager
 */
gboolean prefs_manager_equals_string(PrefsManager *prefs_manager, const gchar *group_name, const gchar *key_name, gchar* value);

/**
 * Gets all the keys from the given PrefsManager
 */
gchar** prefs_manager_get_keys(PrefsManager *prefs_manager, const gchar* group_name);

#endif /* _PREFS_MANAGER_H_ */
